package com.billing.web.controller.archives;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.billing.model.entity.TUserEmergencycontact;
import com.billing.service.UserEmergencycontactService;

@RequestMapping(value="/useremer")
@Controller
public class UserEmergencycontactController {
	@Resource
	private UserEmergencycontactService userEmergencycontactService;
	
	@RequestMapping(value ="/saveemer",method = RequestMethod.POST)
	@ResponseBody
	public String saveemer(HttpServletRequest request,HttpServletResponse response) throws IOException{
		int userid=(Integer) request.getSession().getAttribute("userid");
		String img="";
		String name=request.getParameter("name");
		String relationship=request.getParameter("relationship");
		String mobile=request.getParameter("mobile");
		String age=request.getParameter("age");
		String positions=request.getParameter("positions");
		TUserEmergencycontact userEmergencycontact=new TUserEmergencycontact();
		userEmergencycontact.setAge(Integer.parseInt(age));
		userEmergencycontact.setMobile(mobile);
		userEmergencycontact.setName(name);
		userEmergencycontact.setPositions(positions);
		userEmergencycontact.setRelationship(relationship);
		userEmergencycontact.setUserId(userid);
		int fal=userEmergencycontactService.insertTUserEmergencycontact(userEmergencycontact);
		if(fal>0){
			img="success";
		}else{
			img="fail";
		}
		return img;
	}
		
}
